from tortoise import Tortoise

# MySQL配置
TORTOISE_ORM = {
    "connections": {
        "default": "mysql://root:LJQ20010722S@49.234.36.250:3306/subtle_style"
    },
    "apps": {
        "models": {
            "models": ["models.products", "models.payment", "models.address", "models.user", "models.history",
                        "models.purchaseHistory","aerich.models","models.homepage","models.cart"],
            "default_connection": "default"
        }
    },
    "use_tz": False,
    "timezone": "Asia/Shanghai",
}


# 初始化
async def init_tortoise():
    await Tortoise.init(config=TORTOISE_ORM)
    await Tortoise.generate_schemas()


# 关闭连接
async def close_tortoise():
    await Tortoise.close_connections()


# 支付宝正式环境配置
ALIPAY_CONFIG_PROD = {
    "appid": "2021005173659515",
    "app_private_key_path": "utils/certs/alipay_certs/app_private_key.pem",
    "alipay_public_key_path": "utils/certs/alipay_certs/alipay_public_key.pem",
    "notify_url": "http://adminqqq.free.idcfengye.com/payment/alipay/notify",
    "return_url": "http://v8cba8f5.natappfree.cc/payment/result",
    "sign_type": "RSA2",
    "debug": False
}

# 支付宝沙箱环境配置
ALIPAY_CONFIG_SANDBOX = {
    "appid": "9021000150667921",
    "app_private_key_path": "utils/certs/alipay_certs/sandbox_app_private_key.pem",
    "alipay_public_key_path": "utils/certs/alipay_certs/sandbox_alipay_public_key.pem",
    "notify_url": "http://adminqqq.free.idcfengye.com/payment/alipay/sandbox_notify",
    "return_url": "http://v8cba8f5.natappfree.cc/payment/sandbox_result",
    "sign_type": "RSA2",
    "debug": True
}

# 环境标志位，True 表示使用沙箱环境，False 表示使用正式环境
USE_ALIPAY_SANDBOX = True

# 根据标志位选择配置
ALIPAY_CONFIG = ALIPAY_CONFIG_SANDBOX if USE_ALIPAY_SANDBOX else ALIPAY_CONFIG_PROD


# 微信正式环境配置
WECHATPAY_CONFIG = {
    "appid": "wx2fd097b62e9525f4",
    "mch_id": "1567589221",
    "public_key_id":"PUB_KEY_ID_0115675892212025010300298600001127",
    "private_key_path": "utils/certs/wechat_certs/apiclient_key.pem",
    "public_key_path": "utils/certs/wechat_certs/pub_key.pem",
    "cert_serial_no":"5CF7E191E835A521778FB4D16F98411E2A6FC386",
    "apiv3_key":"23pjf3JDI3deJ049J203Djepd34rerr4",
    "notify_url": "http://adminqqq.free.idcfengye.com/payment/wechat/notify",
    # "return_url":"http://t38c5862.natappfree.cc/payment/result",
    # "cert_dir":"./utils/certs/wechat_certs"
}
